/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package IFSv2.Util;

import IFSv2.Connection.DBConnection;
import java.awt.Image;
import java.awt.Toolkit;
import java.net.URL;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author Fulbert
 */
public class utilSystemPath {
    
    public static String getReportPath() {
        
        String reportPath = null;
        
        try {
            ResultSet rsPath = DBConnection.getActiveConnection().createStatement().executeQuery("SELECT SysConValue FROM syscon WHERE SysconName = 'rptloc'");
            
            if (rsPath.next()) {
                reportPath = rsPath.getString("SysConValue").toString() + "\\";
            }
            rsPath.close();
        } catch (SQLException ex) {
        }
        
        
        return reportPath;
    }

    public static String getLogPath() {
        
        String logPath = null;
        
        try {
            ResultSet rsPath = DBConnection.getActiveConnection().createStatement().executeQuery("SELECT SysConValue FROM syscon WHERE SysconName = 'log'");
            
            if (rsPath.next()) {
                logPath = rsPath.getString("SysConValue").toString() + "\\";
            } 
            rsPath.close();
        } catch (SQLException ex) {
        }    
        
        return logPath;
    }
    
    public static String getKeyPath() {
        
        String keyPath = null;
        
        try {
            ResultSet rsPath = DBConnection.getActiveConnection().createStatement().executeQuery("SELECT SysConValue FROM syscon WHERE SysconName = 'encryptkey'");
            
            if (rsPath.next()) {
                keyPath = rsPath.getString("SysConValue").toString() + "\\";
            } 
            rsPath.close();
        } catch (SQLException ex) {
        }    
        
        return keyPath;
    }
    
    public static String getConfigPath(){
    
        String configPath = null;
        
        try {
            ResultSet rsPath = DBConnection.getActiveConnection().createStatement().executeQuery("SELECT SysConValue FROM syscon WHERE SysconName = 'configloc'");
            
            if (rsPath.next()) {
                configPath = rsPath.getString("SysConValue").toString() + "\\";
            } 
            rsPath.close();
        } catch (SQLException ex) {
        }    
        
        return configPath;
    }
    
    public static Image getFormImage(URL url){
        
        Image image = null;
        
        try{
            image = Toolkit.getDefaultToolkit().getImage(url);
        }
        catch(Exception e){
            System.out.print("No image found");
        }
        return image;
    }
    
}
